﻿{% extends "base.html" %}
{% block scripts %}
{% endblock %}
{% block content %}
        		<h1>Заказы  <img class="icon" src="/media/images/icon_arrow_1.gif" width="11" height="5">{{ order.subj }}</h1>
				
				<div class="order_block">
					<div class="order_header">
						            <img class="pic"
                                     {% if order.user.user_info.avatar %}
                                        src="{{ order.user.user_info.avatar.url }}"
                                        {% if order.user.user_info.avatar.width > order.user.user_info.avatar.height %} width="79" {% else %} height="79" {% endif %}
                                     {% else %}
                                        src="/media/images/img_no.gif" width="79" height="79"
                                     {% endif %}
                                 />
                        
						<div class="info"><a href="/profile/{{ order.user.id }}/">{{ order.user.user_info.last_name }} {{ order.user.user_info.first_name }}</a> <span class="date">({{ order.order_date }})</span></div>
						<h2 class="block_header">{{ order.subj }}</h2>
						{% if order.price %}
                        <dl class="budget"><dt>Бюджет:</dt> <dd>{{ order.price }}р/заказ</dd></dl>
                        {% endif %}
					</div>
					<div class="order_text">
						{{ order.text|linebreaksbr }}
					</div>
					
					<ul class="options">
						{% if order.user == request.user %}
                            <li class="item"><a href="/edit_order/{{ order.id }}/">Редактировать</a></li>
                        {% endif %}
						{% if request.user.companies.count > 0 %}
                            <li class="item"><a href="/response_to_order/{{ order.id }}/">Ответить на заказ <span class="info"></span></a></li>
                        {% else %}
                            <li class="item">Чтобы ответить на заказ<a href="/register_company/">зарегистрируйте компанию<span class="info"></span></a></li>
                        {% endif %}
					</ul>
					
				</div>
				
				<h2 class="block_header">Предложения по заказу</h2>
				<ul class="info_list_1 order_offers_list">
                {% for response in order.responses.all %}
                    <li class="list_item{% if forloop.first %} list_item_first{% endif %}">
				    <img class="pic"
                        {% if response.company.logo %}
                            src="{{ response.company.logo.url }}"
                            {% if response.company.logo.width > response.company.logo.height %} width="79" {% else %} height="79" {% endif %}
                        {% else %}
                            src="/media/images/img_no.gif" width="79" height="79"
                        {% endif %}
                    />

						<div class="item_base">
							<div class="info">
                                <a href="/profile/{{ response.company.owner.id }}/">
                                    {{ response.company.owner.user_info.last_name }} {{ response.company.owner.user_info.first_name }}
                                </a>
                                <span class="date">({{ response.response_date }})</span></div>
							<dl class="info">
								<dt>Компания:</dt>
									<dd><a href="/company/{{ response.company.id }}/">{{ response.company.name }}</a></dd>
							</dl>
                            <dl>
                                {{ response.text }}
                            </dl>
						</div>
						{% if request.user == order.user %}
                        <ul class="options">
							{% if response.active %}
                            <li class="item"><a href="/decline_executor/{{ response.id }}/"><img class="icon" src="/media/images/icon_refuse.png" width="14" height="14">Отказать</a></li>
							<li class="item"><a href="/accept_executor/{{ response.id }}/"><img class="icon" src="/media/images/icon_performer.png" width="14" height="14">Исполнитель</a></li>
                            {% else %}
                            <li class="item">Предложение отклонено</li>
                            {% endif %}
						</ul>
                        {% endif %}
					</li>
                {% endfor %}

				</ul>
				
{% endblock %}